#ifndef WORLD_HPP_INCLUDED
#define WORLD_HPP_INCLUDED

#include <vector>

#include "city_fwd.hpp"
#include "formula_fwd.hpp"
#include "gamemap.hpp"
#include "government_fwd.hpp"
#include "tile_fwd.hpp"
#include "tile_logic.hpp"
#include "unit_fwd.hpp"
#include "wml_node_fwd.hpp"

class world
{
public:
	explicit world(wml::const_node_ptr node);
	hex::gamemap& map() { return map_; }
	const hex::gamemap& map() const { return map_; }

	void add_unit(const hex::location& loc, unit_ptr u);
	void remove_unit(unit_ptr u);
	city_ptr add_city(wml::const_node_ptr node, const hex::location& loc, government_ptr gov);

	int move_cost(const hex::location& loc, hex::DIRECTION dir) const;

	void calculate_trades();
	void pay_workers();
	void build_projects();

	const std::vector<government_ptr>& sides() const { return sides_; }
	std::vector<government_ptr>& sides() { return sides_; }

	const unit_map& units() const { return units_; }
	const unit_list& units_on_tile(const hex::location& loc) const;

	void build_road(const hex::location& loc, hex::DIRECTION dir);

	void weather_next_turn();
	int weather() const { return weather_y_; }

	const std::vector<city_ptr>& cities() const { return cities_; }
private:
	hex::gamemap map_;
	std::vector<city_ptr> cities_;
	std::vector<government_ptr> sides_;

	unit_map units_;

	int weather_x_;
	int weather_y_;
	game_logic::const_formula_ptr weather_next_turn_;
	game_logic::const_formula_ptr weather_function_;
};

#endif
